/* 标签费用 */

import http from "@/api";

import { PORT1 } from "@/api/config/servicePort";

import { MerakXTableQuery } from "@/components/MerakXTable";

export interface OptionType {
  value: string | number;
  label: string;
  [k: string]: any;
}

/**
 * 获取缴费记录下拉选项
 * @param type supplier: 缴费商家 payment_type: 付款方式 payer_payee: 付款方及收款方 operator: 经手人 pay_factory_id: 贴标工厂
 * @param value 币种值
 */
export const getSelectOptions = (data: {
  type: "supplier" | "payment_type" | "payer_payee" | "operator" | "pay_factory_id";
  value?: string | number;
}) => http.post<Record<string, any>>(`${PORT1}/km/markings-payment/form-select`, { ...data }, { loading: false });

// 获取有商家的缴费记录下拉选项
export const getPaymentOptions = (data: { supplier_id: string | number; currency: string | number }) =>
  http.post<Record<string, OptionType[]>>(
    `${PORT1}/km/markings-payment/payment-detail-search-item`,
    { ...data },
    { loading: false }
  );

// 获取支出明细的下拉选项
export const getOutlayOptions = (data: Record<string, any>) =>
  http.post<Record<string, OptionType[]>>(
    `${PORT1}/km/markings-payment/expenditure-detail-search-item`,
    { ...data },
    { loading: false }
  );

// 新增缴费记录
export const createPayment = (data: Record<string, any>) =>
  http.post(`${PORT1}/km/markings-payment/create-payment`, { ...data }, { loading: false });

// 有商家的缴费记录保存
export const savePayment = (data: Record<string, any>) =>
  http.post(`${PORT1}/km/markings-payment/edit-payment-detail`, { ...data }, { loading: false });

// 删除缴费明细
export const deletePayment = (data: Record<string, any>) =>
  http.post(`${PORT1}/km/markings-payment/delete-payment-detail`, { ...data }, { loading: false });

// 编辑支出
export const editOutlay = (data: Record<string, any>) =>
  http.post<Record<string, any>>(`${PORT1}/km/markings-payment/expenditure-detail-editable`, { ...data }, { loading: false });

// 获取缴费明细表头
export const getPaymentColumns = (data: Record<string, any>, queueId?: string) =>
  http.post<MerakXTableQuery.Columns>(
    `${PORT1}/km/markings-payment/payment-detail-field`,
    { ...data },
    { queueId, loading: false }
  );

// 获取缴费明细列表数据
export const getPaymentData = (data: Record<string, any>, queueId?: string) =>
  http.post<{ table_data: MerakXTableQuery.Records; [k: string]: any }>(
    `${PORT1}/km/markings-payment/payment-detail`,
    { ...data },
    { queueId, loading: false }
  );

// 获取支出明细表头
export const getOutlayColumns = (data: Record<string, any>, queueId?: string) =>
  http.post<MerakXTableQuery.Columns>(
    `${PORT1}/km/markings-payment/expenditure-detail-field`,
    { ...data },
    { queueId, loading: false }
  );

// 获取支出明细列表数据
export const getOutlayData = (data: Record<string, any>, queueId?: string) =>
  http.post<{ table_data: MerakXTableQuery.Records; [k: string]: any }>(
    `${PORT1}/km/markings-payment/expenditure-detail`,
    { ...data },
    { queueId, loading: false }
  );
